home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / mail / mailhand / email-pa.000 / email-pa / email-pager / beepme next >
Text File  |  1995-04-24  |  4KB  |  107 lines

  1. #!/bin/bash
  2.  
  3. # Written by Joshua Koplik <jkoplik@bu.edu>
  4. # ------------------------------------------------------------------------
  5. # This program will use a serial modem to call any pager, alpa-numeric or 
  6. # just plain numeric and it will leave the message  A-B-C-D-E-F
  7. # Where A is the total number of e-mail messages you have waiting.  
  8. # And B-F are the numbers of messages from specific people you chose
  9. # If you have any questions or comments or changes/additions to this code 
  10. # please mail them to the author.
  11.  
  12. # To make this work: read and edit up to the line that says STOP
  13.  
  14. # this is the directory where lock files can be found
  15. LOCKDIR=/var/spool/uucp
  16. # your mail directory including your folder
  17. MAILDIR=/usr/spool/mail/root
  18. # your modem goes here, with no leading /dev/
  19. DEVICE=cua3
  20.  
  21. # this is your beeper number
  22. PHONE=6695673
  23. # this is the account that this is going to be run from
  24. USER=root
  25.  
  26. # UNCOMMENT THE FOLLOWING LINES IF YOU WANT THIS PROGRAM TO GRAB POPMAIL
  27. # ACCOUNT= jkoplik
  28. # PASSWORD= SelfEvident
  29. # MAILSERV= acs-mail.bu.edu
  30. # popclient -3 -u $ACCOUNT -p $PASSWORD -c $MAILSERV >> $MAILDIR$USER.tmp
  31.  
  32. # OK..here comes the hard part... these 5 variables are strings that will 
  33. # occur ONCE AND ONLY ONCE in every mail message from a particular user, 
  34. # for example, if I get mail from Jim Smith <jsmith@smith.com> I would 
  35. # probably want the string to be "<jsmith@" because if you look at the 
  36. # header in the mail file you will see that this string only occurs once.  
  37. # I could also probably do "Jim Smith" safely, because many systems stick 
  38. # the user's name in the header.  This part may require some 
  39. # experimentation to get the numbers exactly right, but "<user@" has given 
  40. # me the best results. (these are NOT case-sensitive)
  41.  
  42. S1="<foo@"
  43. S2="<jkoplik@"
  44. S3="<oscar.meyer@"
  45. S3="Usernames May Work"
  46. S4="But Don't forget the quotes"
  47. S5="these aren't case-sensitive, EiThEr"
  48.  
  49. # This is just like the above section, except this is a line that occurs 
  50. # ONCE and ONLY ONCE in __EVERY__ mail message...these are somewhat hard to 
  51. # come by, as there are fre things that fit this criteria, but "From:" has 
  52. # worked for me, although this gets screwed up sometimes when messages are 
  53. # forwarded, but even if it's not exactly right, the worst thing that 
  54. # happes is you get the wrong number of messages. (this IS case-sensitive)
  55.  
  56. S0="From:"
  57.  
  58. # -----------------------STOP-----STOP-----STOP-----------------------------
  59. # you shouldn't need to edit anything below this line (but feel free to)
  60.  
  61.  
  62.  
  63. # this tests if the modem is locked, and will quit the program if the 
  64. # modem is locked.
  65.  
  66. if [ -f $LOCKDIR/LCK..$DEVICE ]
  67.     then
  68.     exit 1
  69.     fi
  70.  
  71. # uncomment these lines if you want to override file locking.
  72. # if [ -f $LOCKDIR/LCK..$DEVICE ]
  73. #    then
  74. #    rm -rf $LOCKDIR/LCK..$DEVICE
  75. #    fi
  76.  
  77. # if you don't have mail we don't need to run this now do we :)
  78. # if you don't allow fingers you need to remove this section
  79.  
  80. if finger root |grep -q -i "no mail"
  81. then
  82. exit 1
  83. fi
  84.  
  85.  
  86. # check the number of messages and dial the modem
  87. MAIL=$MAILDIR.tmp
  88.  
  89. CODE=`grep $S0 $MAIL |wc -l |cut -c7`*`grep -i -e $S1 $MAIL |wc -l |cut -c7`*`grep -i -e $S2 $MAIL |wc -l |cut -c7`*`grep -i -e $S3 $MAIL |wc -l |cut -c7`*`grep -i -e $S4 $MAIL |wc -l |cut -c7`*`grep -i -e $S5 $MAIL |wc -l |cut -c7`
  90.  
  91. ( stty 38400 -tostop
  92.   chat ABORT "NO CARRIER" "" ATM0 OK "ATDT$PHONE ,,, DT$CODE" 
  93. ) < /dev/$DEVICE > /dev/$DEVICE 
  94.  
  95. # this is how long to wait before hanging up--change this value as needed
  96.  
  97. sleep 16
  98.  
  99.     rm -rf $LOCKDIR/LCK..$DEVICE
  100. cat $MAIL >> $MAILDIR
  101. rm $MAIL
  102. chmod 660 $MAILDIR
  103. chmod 660 $MAIL
  104. chgrp mail $MAIL
  105. chgrp mail $MAILDIR
  106.  
  107.